package com.sike.netty.jinjie.channelPipeline.dynamic;

import io.netty.channel.ChannelHandlerContext;
import io.netty.channel.ChannelInboundHandlerAdapter;

public class DynamicChannelHandler02 extends ChannelInboundHandlerAdapter {
    @Override
    public void channelRead(ChannelHandlerContext ctx, Object msg) throws Exception {
        System.out.println("进入 DynamicChannelHandler02");

        if ("01\r\n".equals(msg.toString())) {
            // handler03 添加到 handler01 后
            ctx.channel().pipeline().addAfter("handler01","handler03",new DynamicChannelHandler03());
            // handler04 添加到 handler02 后
            ctx.channel().pipeline().addAfter("handler02","handler04",new DynamicChannelHandler04());
        }

        super.channelRead(ctx, msg);
    }
}
